<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    for(let i = 1; i <= 5; i ++){
        setTimeout(function timer(){ console.log(i) }, 0)
    }
    for(var i = 1; i <= 5; i ++){
            let j = i
            setTimeout(function timer(){ console.log(j) }, 0)
    }
    for(var i = 1; i <= 5; i ++){
        (
            function(j){
                setTimeout(function timer(){ console.log(j) }, 0)
            }
        )(i)

    }
    for(var i = 1; i <= 5; i ++){
        setTimeout(function timer(j){ console.log(j) }, 0,i)
    }
</script>
</html>